<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
	<head>
		<meta charset="utf-8">
		<title>教师端登录/注册</title>
		<script src="../static/js/jquery-3.3.1.min.js"></script>
		<script src="../static/js/bootstrap.min.js"></script>
		<link href="../static/css/bootstrap.min.css" type="text/css" rel="stylesheet" />

		<script type="text/javascript" src="../static/js/wow.min.js"></script>
		<link href="../static/css/animate.css" type="text/css" rel="stylesheet"/>


		<style>
			.page-header h3{
				font-weight: 800;
			}
		</style>

		<script>
			$(document).ready(function(){

				// 登录
				$('.loginBtn').click(function () {

					if ($('#loginId').val().length==0){
						alert("账号不能为空")
						return false;
					}
					if ($('#loginPassword').val().length==0){
						alert("密码不能为空")
						return false;
					}

					$.post(
							"${pageContext.request.contextPath}/teacherLogin",
							$('#loginForm').serialize(),
							function (data) {
								if (data == 0) {
									alert("登录失败");
								}else if(data==1){
									var $url = "${pageContext.request.contextPath}" +'/jsp/admin/teacher/admin.jsp';
									$(window).attr('location',$url);

								}
							}
					)
				});

				//展示注册页
				$('.registerNewBtn').click(function(){		
					
					$('.register').show();
					$('.login').hide();
					return false;
				});

				//展示登录页面
				$('.loginNewBtn').click(function(){		
					
					$('.register').hide();
					$('.login').show();
					return false;
				});

				// 注册
				$('.registerBtn').click(function () {

					if ($('#teacherId').val().length==0){
						alert("账号不能为空")
						return false;
					}
					if ($('#teacherPassword').val().length==0){
						alert("密码不能为空")
						return false;
					}

					if ($('#confirmPassword').val()!=$('#teacherPassword').val()){
						alert("两次密码不相同")
						return false;
					}
					if ($('#teacherName').val().length==0){
						alert("姓名不能为空")
						return false;
					}

					$.post(
							"${pageContext.request.contextPath}/teacherRegister", //jsp页面地址
							$('#registerForm').serialize(),
							function (data) {
								console.log(data);
								if(data>0){
									alert("注册成功！");
								}else{
									alert("注册失败！")
								}
							}
					)
				});



				//检查账号是否被占用
				$('#teacherId').blur(function () {
					$.get(
							"${pageContext.request.contextPath}/queryTeacherIdIsExist",
							{teacherId:$('#teacherId').val()},
							function (data) {
								if(data>0){
									$('.teacherIdTip').text("该账号已被注册！");
								}else{
									$('.teacherIdTip').text("");
								}
							}
					);
				});

				$('.index').click(function () {
					var $url = "${pageContext.request.contextPath}" +'/index.jsp';
					$(window).attr('location',$url);
				});

				//wow 动画
				var wow = new WOW({
					boxClass: 'wow',
					animateClass: 'animated',
					offset: 0,
					mobile: true,
					live: true
				});
				wow.init();
				
			});
		</script>

	</head>
	<body background="../static/img/bg.png">
		<div class="contains" style="width: 50%;  margin: 200px auto;">
			<div class="logo text-center"><img src="../static/img/logo.png" width="200px" /></div>

			<div class="login">
				<script>
					$('.login').show();
				</script>
				<div class="panel panel-collapse panel-primary text-center">
					<div class="page-header panel-danger">
						<h3 class="text-info  wow bounceInDown"  data-wow-duration="1s" data-wow-delay="0.5s" data-wow-offset="10"
							data-wow-iteration="1">欢迎使用网络在线选课系统-教师登录</h3>
					</div>
					<div class="panel-body text-center">
						<form class="form form-horizontal" id="loginForm">
							<div class="form-group form-inline">
								<label class="wow fadeInDown" data-wow-duration="1s" data-wow-delay="0.2s" data-wow-offset="10"
									   data-wow-iteration="1">教师账号：<input type="text" class="form-control" name="teacherId" id="loginId" placeholder="请输入账号" /></label>
								<label class="tip userTip text-danger"></label>
							</div>
							<div class="form-group form-inline">
								<label class="wow fadeInDown" data-wow-duration="1s" data-wow-delay="0.2s" data-wow-offset="10"
									   data-wow-iteration="1">教师密码：<input type="password" class="form-control" name="teacherPassword" id="loginPassword" placeholder="请输入密码" /></label>
								<label class="tip passwordTip text-danger"></label>
							</div>
							<div class="form-group form-inline">
								<button class="btn btn-sm btn-link"><a href="checkUser.jsp">忘记密码?</a></button>
								|
								<button class="btn btn-sm btn-link registerNewBtn">注册一个新账号?</button>
							</div>
							<div class="form-group form-inline">
								<button type="button" class="btn btn-info  loginBtn wow bounceInRight" data-wow-duration="1s" data-wow-delay="0.5s" data-wow-offset="10"
										data-wow-iteration="1">登录</button>
								<button type="button" class="btn btn-danger index wow bounceInLeft"   data-wow-duration="1s" data-wow-delay="0.5s" data-wow-offset="10"
										data-wow-iteration="1">主页</button>
								<label class="tip statusTip text-danger"></label>
							</div>
						</form>
					</div>
					<div class="panel-footer ">
						<h5>@2019-2019 JSP期末项目</h5>
					</div>

				</div>
			</div>


			<div class="register">
				<script>
					$('.register').hide();
				</script>
				<div class="panel panel-collapse panel-primary text-center">
					<div class="page-header panel-danger">
						<h3 class="text-info wow bounceInDown"  data-wow-duration="1s" data-wow-delay="0.5s" data-wow-offset="10"
							data-wow-iteration="1">欢迎使用网络在线选课系统-教师注册</h3>
					</div>
					<div class="panel-body text-center">
						<form class="form form-horizontal" id="registerForm">
							<div class="form-group form-inline">
								<label class="wow fadeInDown" data-wow-duration="1s" data-wow-delay="0.2s" data-wow-offset="10"
									   data-wow-iteration="1">教师账号：<input type="text" class="form-control" name="teacherId" id="teacherId" placeholder="请输入账号" /></label>
								<label class="tip teacherIdTip text-danger"></label>
							</div>
							<div class="form-group form-inline">
								<label class="wow fadeInDown" data-wow-duration="1s" data-wow-delay="0.2s" data-wow-offset="10"
									   data-wow-iteration="1">教师密码：<input type="password" class="form-control" name="teacherPassword" id="teacherPassword" placeholder="请输入密码" /></label>
								<label class="tip passwordTip text-danger"></label>
							</div>
							<div class="form-group form-inline">
								<label class="wow fadeInDown" data-wow-duration="1s" data-wow-delay="0.2s" data-wow-offset="10"
									   data-wow-iteration="1">确认密码：<input type="password" class="form-control" id="confirmPassword" placeholder="请再输入密码" /></label>
								<label class="tip confirmTip text-danger"></label>
							</div>
							<div class="form-group form-inline">
								<label class="wow fadeInDown" data-wow-duration="1s" data-wow-delay="0.2s" data-wow-offset="10"
									   data-wow-iteration="1">教师姓名：<input type="text" class="form-control" name="teacherName" id="teacherName" placeholder="请输入姓名" /></label>
								<label class="tip nameTip text-danger"></label>
							</div>
							<div class="form-group form-inline">
								<label class="wow fadeInDown" data-wow-duration="1s" data-wow-delay="0.2s" data-wow-offset="10"
									   data-wow-iteration="1">教师级别：
									<select class="form-control level" name="teacherGrade">
										<option value="辅导员">辅导员</option>
										<option value="讲师">讲师</option>
										<option value="高级讲师">高级讲师</option>
										<option value="教授">教授</option>
										<option value="主任">主任</option>
										<option value="校长">校长</option>
									</select>
								</label>
								<label class="tip nameTip text-danger"></label>
							</div>

							<div class="form-group form-inline">
								<label class="wow fadeInDown" data-wow-duration="1s" data-wow-delay="0.2s" data-wow-offset="10"
									   data-wow-iteration="1">教师类型：
									<div class="radio" name="teacherType">
										<label>
											<input type="radio" value="全职" name="teacherType" checked>
											全职
										</label>
											
									</div>
									<div class="radio" name="teacherType">
										<label>
											<input type="radio" name="teacherType" value="兼职">
											兼职
										</label>
									</div>

								</label>
								<label class="tip nameTip text-danger"></label>
							</div>

							<div class="form-group form-inline">
								<label class="wow fadeInDown" data-wow-duration="1s" data-wow-delay="0.2s" data-wow-offset="10"
									   data-wow-iteration="1">教师系部：
									<select class="form-control department" name="department">
										<option value="法政系">法政系</option>
										<option value="外语系">外语系</option>
										<option value="艺术系">艺术系</option>
										<option value="管理系">管理系</option>
										<option value="经济系">经济系</option>
										<option value="社体系">社体系</option>
										<option value="电气系">电气系</option>
										<option value="计算机系">计算机系</option>
									</select>

								</label>
								<label class="tip departmentTregisterip text-danger"></label>
							</div>
							<div class="form-group form-inline">
								<button class="btn btn-danger  registerBtn wow bounceInRight"   data-wow-duration="1s" data-wow-delay="0.5s" data-wow-offset="10"
										data-wow-iteration="1">注册</button>
								<button type="button" class="btn btn-danger index wow bounceInLeft"   data-wow-duration="1s" data-wow-delay="0.5s" data-wow-offset="10"
										data-wow-iteration="1">主页</button>
								<label class="tip statusTip text-danger"></label>
							</div>
							<div class="form-group form-inline">

								已经有账户了?
								<button class="btn  btn-link loginNewBtn">点击登录</button>
							</div>
						</form>

					</div>
					<div class="panel-footer ">
						<h5>@2019-2020 JSP期末项目</h5>
					</div>

				</div>
			</div>


		</div>
	</body>
</html>
